package com.fy.qu.controller;

import com.fy.core.context.AuthContext;
import com.fy.core.dto.PageDto;
import com.fy.core.vo.ApiRest;
import com.fy.core.vo.PageResult;
import com.fy.qu.dto.QuAddDto;
import com.fy.qu.dto.QuSearchDto;
import com.fy.qu.entity.Qu;
import com.fy.qu.service.QuService;
import com.fy.sys.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 问题题目 前端控制器
 * </p>
 *
 * @author hxd
 * @since 2023-06-13
 */
@RestController
@RequestMapping("/qu")
@CrossOrigin
public class QuController {
    @Autowired
    private QuService quService;
    @PostMapping("page")
    public PageResult<Qu> findPage(@RequestBody PageDto<QuSearchDto> pageDto){

        //获取用户信息
        User user= AuthContext.getUser();
        System.out.println("user = " + user);

        return quService.findPage(pageDto);
    }
    @PostMapping("save")
    public ApiRest save(@RequestBody QuAddDto quAddDto){
        return quService.save(quAddDto);
    }
    @GetMapping("find/{quId}")
    public ApiRest findByQuId(@PathVariable("quId") String quId){
        return  quService.findByQuId(quId);
    }






}
